package com.example.anew.journey.mynewjourney.firstchangelogic.FirstChangeSetting;

import android.content.Intent;
import android.view.View;
import android.widget.Button;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.example.anew.journey.mynewjourney.R;
import com.example.anew.journey.mynewjourney.base.FirstChangeAllBaseActivity;
import com.example.anew.journey.mynewjourney.firstchangelogic.FirstChangeSetting.persenter.FirstChangeSettingPersenter;
import com.example.anew.journey.mynewjourney.firstchangelogic.FirstChangeSetting.view.ISFirstChangeSettingView;
import com.example.anew.journey.mynewjourney.firstchangelogic.firstChangeAboutApp.FirstChangeAboutAppActivity;
import com.example.anew.journey.mynewjourney.firstchangelogic.firstChangeAccountBinding.FirstChangeAccountBindingActivity;
import com.example.anew.journey.mynewjourney.firstchangelogic.firstChangeChangePassword.FirstChangeChangePasswordActivity;
import com.example.anew.journey.mynewjourney.firstchangelogic.firstChangeFeedBack.FirstChangeFeedBackActivity;
import com.example.anew.journey.mynewjourney.firstchangelogic.firstChangeNewMessager.FirstChangeNewMessagerActivity;
import com.example.anew.journey.mynewjourney.logic.registeredOrLogin.RegisteredOrLoginActivity;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * 杭州惟君医疗科技有限公司11
 * Created by 20433 on 2018/3/16
 */

public class FirstChangeSettingActivity extends FirstChangeAllBaseActivity  implements ISFirstChangeSettingView,View.OnClickListener {
    @Bind(R.id.activity_first_change_setting_rl_account_binding)
    RelativeLayout activityFirstChangeSettingRlAccountBinding;
    @Bind(R.id.activity_first_change_setting_rl_change_password)
    RelativeLayout activityFirstChangeSettingRlChangePassword;
    @Bind(R.id.activity_first_change_setting_rl_about_app)
    RelativeLayout activityFirstChangeSettingRlAboutApp;
    @Bind(R.id.activity_first_change_setting_rl_clear_cache)
    RelativeLayout activityFirstChangeSettingRlClearCache;
    @Bind(R.id.activity_first_change_setting_rl_new_message)
    RelativeLayout activityFirstChangeSettingRlNewMessage;
    @Bind(R.id.activity_first_change_setting_rl_feedback)
    RelativeLayout activityFirstChangeSettingRlFeedback;
    @Bind(R.id.activity_first_change_setting_bt_log_out)
    Button activityFirstChangeSettingBtLogOut;
    private View view;

    private FirstChangeSettingPersenter mFirstChangeSettingPersenter = new FirstChangeSettingPersenter(this);
    private TextView tv_cancel;
    private TextView tv_confirm;

    /**
     * @desc 主要内容的布局资源填充进来
     */
    @Override
    protected View setMainContentView() {
        view = View.inflate(this, R.layout.activity_first_change_setting, null);
        ButterKnife.bind(this,view);
        return view;
    }

    /**
     * @desc 初始化数据 onCreate()
     */
    @Override
    protected void initView(View view) {
        displayToolbar();
        displayReturn();
        displayTvName();

        setToolbarBg(0xff2196F3);
        setReturnrePictuResources(R.mipmap.return_02);
        setTvNameEachAttribute(20, 0xffffffff, "设置");

        initDate();
    }

    private void initDate() {
        activityFirstChangeSettingRlAccountBinding.setOnClickListener(this);
        activityFirstChangeSettingRlChangePassword.setOnClickListener(this);
        activityFirstChangeSettingRlAboutApp.setOnClickListener(this);
        activityFirstChangeSettingRlClearCache.setOnClickListener(this);
        activityFirstChangeSettingRlNewMessage.setOnClickListener(this);
        activityFirstChangeSettingRlFeedback.setOnClickListener(this);
        activityFirstChangeSettingBtLogOut.setOnClickListener(this);
    }

    /**
     * @desc Activity 销毁 释放资源
     */
    @Override
    protected void releaseResources() {
        ButterKnife.unbind(view);
    }

    /**
     * @desc 网络监听 用于提示用户有网络了
     */
    @Override
    protected void promptHaveInternet() {

    }

    /**
     * @desc 网络监听 用于提示用户没有网络了
     */
    @Override
    protected void promptNoInternet() {

    }

    /**
     * @desc 点击分享按钮
     */
    @Override
    protected void onClickShared() {

    }

    /**
     * @desc 点击发布按钮
     */
    @Override
    protected void onClickRelease() {

    }

    /**
     * @desc 点击返回按钮
     */
    @Override
    protected void onClickReturn() {
        finish();
    }


    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.activity_first_change_setting_rl_account_binding: //账号绑定
                mFirstChangeSettingPersenter.onClickAccountBinding();
                break;
            case R.id.activity_first_change_setting_rl_change_password:  //修改密码
                mFirstChangeSettingPersenter.onClickChangePassword();
                break;
            case R.id.activity_first_change_setting_rl_about_app:  //关于APP
                mFirstChangeSettingPersenter.onClickAboutApp();
                break;
            case R.id.activity_first_change_setting_rl_clear_cache: //清除缓存
                mFirstChangeSettingPersenter.onClickClearCache(this);
                break;
            case R.id.activity_first_change_setting_rl_new_message: //新消息通知
                mFirstChangeSettingPersenter.onClickNewMessager();
                break;
            case R.id.activity_first_change_setting_rl_feedback:  //意见反馈
                mFirstChangeSettingPersenter.onClickFeedBack();
                break;
            case R.id.activity_first_change_setting_bt_log_out:  //退出登录
                mFirstChangeSettingPersenter.onClicklogOut(this);
                break;
            case R.id.clear_cache_popu_tv_cancel:    //清除缓存 取消
                mFirstChangeSettingPersenter.onClickClearCacheCancel();
                break;
            case R.id.clear_cache_popu_tv_confirm:  //清除缓存 确认
                mFirstChangeSettingPersenter.onClickClearCacheConfirm();
                break;
        }
    }
    // 跳转到账号绑定页面
    @Override
    public void toAccountBindingPager() {
        Intent intent =  new Intent(FirstChangeSettingActivity.this, FirstChangeAccountBindingActivity.class);
        startActivity(intent);
    }
    // 跳转到修改密码页面
    @Override
    public void toChangePasswordPager() {
        Intent intent =  new Intent(FirstChangeSettingActivity.this, FirstChangeChangePasswordActivity.class);
        startActivity(intent);
    }
    // 跳转到关于APP页面
    @Override
    public void toAboutAppPager() {
        Intent intent =  new Intent(FirstChangeSettingActivity.this, FirstChangeAboutAppActivity.class);
        startActivity(intent);
    }
    // 跳转到新消息通知页面
    @Override
    public void toNewMessagerPager() {
        Intent intent =  new Intent(FirstChangeSettingActivity.this, FirstChangeNewMessagerActivity.class);
        startActivity(intent);
    }
    // 跳转到意见反馈页面
    @Override
    public void toFeedBackPager() {
        Intent intent =  new Intent(FirstChangeSettingActivity.this, FirstChangeFeedBackActivity.class);
       // intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
        startActivity(intent);
    }
    // 显示提示Toast信息
    @Override
    public void showToastInformation(String str) {
        Toast.makeText(this,str,Toast.LENGTH_SHORT).show();
    }
    // 显示进度
    @Override
    public void displayProgress() {

    }
    // 隐藏进度
    @Override
    public void hiddenProgress() {

    }
    //获取 点击 清除缓存的弹框控件
    @Override
    public void findClearCacheView(View view) {
        tv_cancel = view.findViewById(R.id.clear_cache_popu_tv_cancel);
        tv_confirm = view.findViewById(R.id.clear_cache_popu_tv_confirm);

        tv_cancel.setOnClickListener(this);
        tv_confirm.setOnClickListener(this);
    }
    //点击退出登陆
    @Override
    public void logOut() {
        Intent intent =  new Intent(FirstChangeSettingActivity.this, RegisteredOrLoginActivity.class);
        intent.putExtra("my_page_integration_code",1);
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
        startActivity(intent);
        finish();
    }
}
